<?php 
$category = PostCategory::model()->findAllByAttributes(array('status' => 1));

$criteria = new CDbCriteria();
$criteria->limit = 4;
$criteria->order = 'sorter ASC';
$criteria->order = 'date_created DESC';
$product = Product::model()->findAllByAttributes(array('is_feature' => 1, 'status' => 1), $criteria);

$siteInfo = SiteInfo::model()->findAll();
$siteInfo = CHtml::listData($siteInfo, 'key', 'value');
?>
<div class="spotlight">
            <img src="<?php echo Yii::app()->theme->baseUrl ?>/images/cat/3.jpg" alt="Category Image" class="spl-thumb"/>
            <h2 class="spl-info small">Tin tức</h2>
        </div><!-- /.spotlight -->
        <section class="main-content container">
            <div class="news-left">
				<?php 
				$criteria = new CDbCriteria;
				$criteria->condition = "t.status = 1";
				$criteria->order = 'id DESC';
				$dataProvider = new CActiveDataProvider('Post', array(
						'criteria'=>$criteria,
						'pagination' => array('pageSize' => 4),
				
				));
				
				$this->widget('zii.widgets.CListView', array(
						'dataProvider'=>$dataProvider,
						'itemView'=>'_news',   
						'summaryText' => '',
						'enablePagination' => true,
						'sorterHeader' => false,
						'sorterFooter' => false,
						'template' => "{items}\n{pager}",
						'pager' => array(
							'header' => '',	
							'maxButtonCount' => 5,
						),
				));
				?>
            </div><!-- /.news-left -->
            <aside class="news-widgets">
                <div class="nw-box subnav">
                    <h4>Chuyên mục</h4>
                    <div class="nwb-content">
                        <ul>
                        	<?php if($category):foreach ($category as $c): ?>
                            <li><a href="<?php echo '/news/category/id/' . $c->id ?>"><?php echo $c->title ?></a></li>
                        	<?php endforeach;endif; ?>
                        </ul>
                    </div>
                </div><!-- /.subnav -->
                <div class="nw-box hasthumb">
                    <h4>Sản phẩm mới</h4>
                    <div class="nwb-content">
                        <ul>
	                    	<?php if($product):foreach($product as $p): ?>
                           <li>
                                <a href="<?php echo '/product/detail/id/' . $p->id ?>" class="nwb-thumb"><img src="<?php echo $p->thumbnail ?>" alt="<?php echo $p->title ?>"/></a>
                                <h3 class="nwb-title"><a href="<?php echo '/product/detail/id/' . $p->id ?>"><?php echo $p->title ?></a></h3>
                                <a href="<?php echo '/product/category/id/' . $p->productCategory->id ?>" class="nwb-cat"><?php echo $p->productCategory->title ?></a>
                           </li>
                           <?php endforeach;endif; ?>
                        </ul>
                    </div>
                </div><!-- /.hasthumb -->
                <div class="nw-box newsinfo">
                    <h4><?php echo isset($siteInfo['site_short_name']) ? $siteInfo['site_short_name'] : 'siteInfo:site_short_name'; ?></h4>
                    <div class="nwb-content">
                        <p>
                            <?php echo isset($siteInfo['short_about']) ? $siteInfo['short_about'] : 'siteInfo:short_about'; ?>
                        </p>
                        <ul>
                           <li><p><span class="txtred">Địa chỉ</span><?php echo isset($siteInfo['address']) ? $siteInfo['address'] : 'siteInfo:address'; ?></p></li>
                           <li><p><span class="txtred">Số điện thoại</span><?php echo isset($siteInfo['mobile']) ? $siteInfo['mobile'] : 'siteInfo:mobile'; ?> - <?php echo isset($siteInfo['tel']) ? $siteInfo['tel'] : 'siteInfo:tel'; ?></p></li>
                           <li><p><span class="txtred">Email</span><?php echo isset($siteInfo['email_info']) ? $siteInfo['email_info'] : 'siteInfo:email_info'; ?></p></li>
                        </ul>
                        <div class="cti-social">
                            <ul>
                                <li><a href="<?php echo isset($siteInfo['contact_facebook']) ? $siteInfo['contact_facebook'] : 'siteInfo:contact_facebook'; ?>" class="icon-social">Mai Hoang Facebook</a></li>
		                        <li><a href="<?php echo isset($siteInfo['contact_googleplus']) ? $siteInfo['contact_googleplus'] : 'siteInfo:contact_googleplus'; ?>" class="icon-social gplus">Mai Hoang GooglePlus</a></li>
		                        <li><a href="<?php echo isset($siteInfo['contact_mail']) ? $siteInfo['contact_mail'] : 'siteInfo:contact_email'; ?>" class="icon-social mail">Mai Hoang Email</a></li>
		                        <li><a href="<?php echo isset($siteInfo['contact_site']) ? $siteInfo['contact_site'] : 'siteInfo:contact_site'; ?>" class="icon-social web">Mai Hoang Website</a></li>
                            </ul>
                            <div class="clear"></div>
                        </div>
                    </div>
                </div><!-- /.newsinfo -->
            </aside>
            <div class="clear"></div>
        </section><!-- /.main-content -->